﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 晨曦超市管理系统.进货
{
    public partial class type : Form
    {
        public type()
        {
            InitializeComponent();
        }
        string name1 = "TypeName";
        string UserNameID1 = "TypeID";
        private void type_Load(object sender, EventArgs e)
        {
            BindCbData();
        }
        DataTable JIngban;
        private void BindCbData()
        {
            comboBox1.Items.Clear();//先清除所有内容再绑定
            try
            {
                string strSql = "SELECT *FROM Type ORDER BY TypeID";
                Reusing.XiaLa(comboBox1, name1, UserNameID1, JIngban, strSql);
            }
            catch (Exception ex)
            {
                //捕获到了异常则提示
                MessageBox.Show(ex.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            try
            {
                string TypeName = textBox1.Text.Trim();
                string ParentID = comboBox1.SelectedValue.ToString();
                string sqlstr1 = "insert into Type(TypeName,ParentID) values('" + TypeName + "'," + ParentID + ")";
                bool duicuo = DBHelper.QEX(sqlstr1);
                if (duicuo)
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
